package com.api.shopapi.service.impl;

import com.api.shopapi.entity.CheckinAssessClass;
import com.api.shopapi.mapper.CheckinAssessClassMapper;
import com.api.shopapi.service.CheckinAssessClassService;
import com.api.shopapi.service.CheckinAssessItemService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author maochuan
 */
@Service("CheckinAssessClassServiceImplOne")
public class CheckinAssessClassServiceImpl implements CheckinAssessClassService {
    @Autowired
    private CheckinAssessClassMapper checkinAssessClassMapper;

    @Autowired
    @Qualifier("CheckinAssessItemServiceImplOne")
    private CheckinAssessItemService checkinAssessItemService;

    @Override
    public int insert(CheckinAssessClass checkinAssessClass) {
      return checkinAssessClassMapper.insert(checkinAssessClass);
    }

    @Override
    public int updateByCheckinAssessClassCode(CheckinAssessClass checkinAssessClass) {
        return checkinAssessClassMapper.updateByCheckinAssessClassCode(checkinAssessClass);
    }

    @Override
    public int deleteByCheckinAssessClassCode(String checkinAssessClassCode) {
        return checkinAssessClassMapper.deleteByCheckinAssessClassCode(checkinAssessClassCode);
    }


    @Override
    public CheckinAssessClass getByCheckinAssessClassCode(String checkinAssessClassCode) {
        return checkinAssessClassMapper.getByCheckinAssessClassCode(checkinAssessClassCode);
    }

    @Override
    public CheckinAssessClass getByNameAndInstitutionCode(String name,String institutionCode) {
        return checkinAssessClassMapper.getByNameAndInstitutionCode(name,institutionCode);
    }

    @Override
    public PageInfo<CheckinAssessClass> getPageList(int pageIndex, int pageSize, String institutionCode,int status) {
        PageHelper.startPage(pageIndex, pageSize);
        List<CheckinAssessClass> checkinAssessClasss = checkinAssessClassMapper.getListByInstitutionCode(institutionCode,status);
        PageInfo<CheckinAssessClass> pageInfo = new PageInfo<>(checkinAssessClasss);
        return pageInfo;
    }

    @Override
    public List<CheckinAssessClass> getList(String institutionCode) {
        return checkinAssessClassMapper.getList(institutionCode);
    }
}
